package cn.taobaoke.restful.util;

import cn.taobaoke.restful.domain.ProductEntity;

/**
 * ProductUtil类.
 * +-----------------------------------------------------------------------------------------------+
 * |类名称: ProductUtil                                                                         |
 * |创建时间: 7/26/17                                                                               |
 * |功能简介:                                                                                       |
 * |参考链接:                                                                                       |
 * +-----------------------------------------------------------------------------------------------+
 *
 * @author luch
 */
public class ProductUtil {

    public static String send_product_template(String template, ProductEntity product, String tkl, String more) {
        if (product.getIntro() == null) {
            product.setIntro("");
        }

        return template.replace("{{标题}}", product.getItemName())
                .replace("{{描述}}", product.getIntro())
                .replace("{{原价}}", String.format("%.2f", product.getItemPrice()))
                .replace("{{优惠券}}", String.format("%.2f", product.getCouponAmount()))
                .replace("{{券后价}}", String.format("%.2f", (product.getItemPrice() - product.getCouponAmount())))
                .replace("{{淘口令}}", tkl)
                .replace("{{优惠链接}}", more);
    }

}
